<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue2.js"></script>
</head>
<body>
    <div id="box">
        <div v-choudidi="witchColor">111</div>
    </div>
    <script>
        Vue.directive("choudidi",{
            inserted(el,dind){
                //第一次在父节点中触发
                console.log(el,dind);
                el.style.background=dind.value
            },
            update(el,dind){
                //更新阶段不会在初始化实例时执行
                console.log(el,dind);
                el.style.background=dind.value
            }
        })
      let vm=  new Vue({
            el:'#box',
            data:{
                witchColor:'green'
            }
        })
    </script>
</body>
</html>